#include <iostream>
using namespace std;

struct node
{ int info;
  node *left;
  node *right;
};

node* maketree(int x, node* p, node *q)
{ node * r = new node;
  r->info = x;
  r->left = p;
  r->right = q;
  return r;
}

void preOrder(node * p)
{ if(p!=NULL)
  { cout << p->info << " ";
    preOrder(p->left);
    preOrder(p->right); 
  }
}

int main()
{ 
  node *p = maketree(15,NULL,NULL);
  node *q = maketree(30,NULL,NULL);
  node *r = maketree(20,p,q);
  
  p = maketree(70,r,NULL);
  q = maketree(40,NULL,NULL);
  
  node * root = maketree(50,q,p);
         
  preOrder(root);       
         
  return 0;
}    
